DonationAccount01 = function() {
	donationAccountFrThis = this;
	//클래스에서 사용하는 this
	donationAccountFrThis.bookingDonationAccountJson = null;
	//클래스에서 사용하는 jsonData
	donationAccountFrThis._HTMLDom = null;
	//Dom 오브젝트 객체
}
DonationAccount01.prototype = {
	atferApplyDetailView : function() {
		var mj = new MJson();
		var cm = new ConnectionManager();

		mj.putClient(MJson.CLIENT.USERID, document.globalObj.LOGIN_DATA.userId);
		mj.putPub(MJson.PUB.SID, "DR001");
		mj.putPub(MJson.PUB.SERVICENAME, "DonationDetailView");

		mj.putParameter("reserveSeq", document.globalObj.DONATION_DATA.donation_seq);

		console.log("request : " + mj.getJsonString());
		cm.requestGet(mj.getJsonString(), function(jsonData) {
			console.log("성공 :: 통신");
			if (mj.checkServiceResult(jsonData)) {
				console.log('donationAccountDetailView :: 성공');
				console.log("success :: " + JSON.stringify(jsonData));
				donationAccountFrThis.bookingDonationAccountJson = jsonData;

				//------- UI Display -------//
				var $donationHeader = donationAccountFrThis._HTMLDom.donationHeader;
				var $donationHeaderDt = donationAccountFrThis._HTMLDom.donationHeaderDt;
				var $donationHeaderDd = donationAccountFrThis._HTMLDom.donationHeaderDd;
				var $donationContents = donationAccountFrThis._HTMLDom.donationContents;
				var $donationContentsDd = donationAccountFrThis._HTMLDom.donationContentsDd;

				var applicationDate = '<em>신청기간  :</em>' + jsonData.msp.contents.items.startDt + "~" + jsonData.msp.contents.items.endDt;
				$donationHeaderDt.find('p:eq(0)').html(applicationDate);

				var publicDate = (jsonData.msp.contents.items.publicDate ? jsonData.msp.contents.items.publicDate : jsonData.msp.contents.items.reservDate)
				var publicationDate = '<em>당첨자발표  :</em>' + publicDate;
				$donationHeaderDt.find('p:eq(1)').html(publicationDate);

				var holeCount = new String(jsonData.msp.contents.items.holeCnt);
				var donationTitle = jsonData.msp.contents.items.courseInfoNm + '<em>' + holeCount.slice(0, (holeCount.length - 1)) + 'H</em>';
				$donationHeaderDd.find('h5').html(donationTitle);

				var donationRoundDate = '<em>라운드날짜</em>' + jsonData.msp.contents.items.reservDate + '(' + jsonData.msp.contents.items.bookingDay + ')';
				$donationHeaderDd.find('li:eq(0)').html(donationRoundDate);

				var teaTime = '<em>티타임</em>' + jsonData.msp.contents.items.bookingTime;
				$donationHeaderDd.find('li:eq(1)').html(teaTime);

				var fee = addPeriod(jsonData.msp.contents.items.greenFee);
				var greenFee = '<em>1인 그린피</em><mark>￦' + fee + '</mark>';
				$donationHeaderDd.find('li:eq(2)').html(greenFee);

				$donationHeader.append($donationHeaderDt);
				$donationHeader.append($donationHeaderDd);

				var donatePrice = '응모 <mark>￦ ' + addPeriod(jsonData.msp.contents.items.donatePrice) + '</mark>';
				$donationContentsDd.html(donatePrice);

				$donationContents.append($donationContentsDd);
				//--------------------------//
				donationAccountFrThis.goDonationComplete();
			} else {
				console.log('donationAccountDetailView :: 실패');
			}
		}, function(e) {
			console.log("실패 :: 통신");
		});
	},
	goDonationComplete : function() {
		console.log("goDonationComplete :: called");
		var pop = new Popup();
		pop.confirm("골프인", "￼모바일 결제 준비중 입니다.", "확인", function(index) {
			//TODO 결제용 테스트 경고창
			$.mobile.changePage('donation_view.html');
		});
	},
	onPageShow : function() {
		console.log("DonationAccount01 :: onPageShow");
		this.atferApplyDetailView();
		var $donationHeader = $("#donation_account_fr_header");
		var $donationHeaderDt = $donationHeader.find("dt:first");
		var $donationHeaderDd = $donationHeader.find("dd:first");

		var $donationContents = $("#donation_account_fr_contents");
		var $donationContentsDd = $donationContents.find('dd:first');

		$donationHeader.empty();
		$donationContents.empty();
		this._HTMLDom = {
			"donationHeader" : $donationHeader,
			"donationHeaderDt" : $donationHeaderDt,
			"donationHeaderDd" : $donationHeaderDd,
			"donationContents" : $donationContents,
			"donationContentsDd" : $donationContentsDd,
		}
	}
}
function addPeriod(nStr) {
	nStr += '';
	x = nStr.split(',');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}